﻿Rsd.define('Rsd.Faith.pages.SinglePage', {
    extend: 'Rsd.container.Page',
    requires: [
        'Rsd.controlEx.ModelViewer'],
    xtype: 'single-page',
    width: 480,
    layout: 'fit',
    items: [
        {
            xtype: 'model-viewer'
        }
    ],
    data:null,
    /*
    * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
        var me = this;

        this.on('afterrender', function () {
            me._waiting = Rsd.create('Rsd.control.WaitingBar', {text: '正在加载页面，请稍后...', border: false});
            me._waiting.showDialog();
            me.loadFields();
        });

    },
    /*
    * */
    loadFields:function()
    {
        var me = this;

        Rsd.app.getSchema(me.menu.modelType,function(schema){
            try
            {
                if(schema )
                {
                    var _fields = schema.fields;

                    if(me.menu.labelWidth)
                    {
                        for(var i in _fields)
                        {
                            _fields[i].label.width=  me.menu.labelWidth;
                        }
                    }
                    me.items[0].loadFields(_fields);
                }

            }catch (ex)
            {
                Rsd.error('加载模型结构失败：' ,'Rsd.Faith.pages.SinglePage',  ex);
            }
            me._waiting.close();
        });

    },
    /*
    * */
    loadRecord: function loadRecord(record) {

        this.items[0].loadRecord(record);
    }
});